<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商机')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-opportunity-add">

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">商机名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">录入时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="registerTime" th:value="${#dates.format(now, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">客户：</label>
                <div class="col-sm-8">
                    <select name="customerId"  class="form-control m-b" th:with="type=${@customDictService.selectDictCustomer()}">
                        <option value="">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.title}" th:value="${dict.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">预计签约金额：</label>
                <div class="col-sm-8">
                    <input name="expectAmount" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">预计签约日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="expectTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">协作人：</label>
                <div class="col-sm-8">
                    <input name="cooperator" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-8">
                    <input name="contact" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control m-b" th:with="type=${@dict.getType('opportunity_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商务负责人：</label>
                <div class="col-sm-8">
                    <select name="businessManager"  class="form-control m-b" th:with="type=${@customDictService.selectUserList()}">
                        <option value="0">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.userName}" th:value="${dict.userId}" th:field="${userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">渠道：</label>
                <div class="col-sm-8">
                    <select name="channel" class="form-control m-b" th:with="type=${@dict.getType('opportunity_channel')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">概率：</label>
                <div class="col-sm-8">
                    <select name="probability" class="form-control m-b" th:with="type=${@dict.getType('opportunity_probility')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "erp/opportunity"
        $("#form-opportunity-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-opportunity-add').serialize());
            }
        }

        $("input[name='registerTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='expectTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>